#include<bits/stdc++.h>
using namespace std;
const double eps=1e-7;
int T;
int n, m;
double L, V;
double d, v, a;
int cnt;
bool p[1000001];
int pcnt[1000001];
struct car{
    double d, v, a;
}c[100001];
int tmp;
bool pd(double st, double ed){
    return pcnt[(int)floor(ed)]-pcnt[(int)floor(st)]>0;
}
bool speA=1, speB=1;
double stt[10001];
double edd[10001];
int ppos[10001];
bool vis[10001];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        memset(p,0,sizeof(p));
        memset(pcnt,0,sizeof(pcnt));
        memset(ppos,0,sizeof(ppos));
        memset(stt,0,sizeof(stt));
        memset(edd,0,sizeof(edd));
        cin>>n>>m>>L>>V; cnt=0;
        for(int i=1; i<=n; i++) cin>>c[i].d>>c[i].v>>c[i].a;
        for(int i=1; i<=m; i++) cin>>tmp, p[tmp]=1, ppos[i]=tmp;
        pcnt[0]=p[0];
        for(int i=1; i<=1e6; i++) pcnt[i]=pcnt[i-1]+p[i];
        for(int i=1; i<=n; i++){
            stt[i]=0; edd[i]=L;
            if(c[i].a==0){
                speB=0;
                if(c[i].v>V && pd(c[i].d, L)) cnt++, stt[i]=c[i].d, edd[i]=L;
            }else if(c[i].a>0){
                speA=0;
                double wy=(V*V-c[i].v*c[i].v)/(2*c[i].a)+eps;
                double st=c[i].d+wy;
                if(st<=L && pd(st, L)) cnt++, stt[i]=st, edd[i]=L;
            }else{
                speA=0; speB=0;
                if(c[i].v>V){
                    double wy=(V*V-c[i].v*c[i].v)/(2*c[i].a)-eps;
                    double ed=c[i].d+wy;
                    if(ed>L){
                        if(pd(c[i].d, L)) cnt++, stt[i]=c[i].d, edd[i]=L;
                    }else{
                        if(pd(c[i].d, ed)) cnt++, stt[i]=c[i].d, edd[i]=ed;
                    }
                }
            }
        }
        cout<<cnt<<" ";
        if(speA || speB){
           cout<<m-1<<endl; continue;
        }
        int mx=pow(2,m)-1, ans=INT_MAX;
        for(int i=1; i<=mx; i++){
            memset(vis,0,sizeof(vis));
            int ix=i, pi=1, onecnt=0;
            while(ix>0){
                if(ix&1){
                    onecnt++;
                    for(int cr=1; cr<=n; cr++){
                        if(stt[cr]<=ppos[pi] && edd[cr]>=ppos[pi]){
                            vis[cr]=1;
                        }
                    }
                }
                ix>>=1; pi++;
            }
            bool f=1;
            for(int cr=1; cr<=n; cr++) f=f&vis[cr];
            if(f) ans=min(ans, onecnt);
        }
        cout<<m-ans<<endl;
    }
    return 0;
}

